package com.atguigu.excel.excelWrite;

import com.alibaba.excel.EasyExcel;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: fangshicai
 * @Date: 2022/1/24 22:30
 * @Description: 实现写入excel功能
 */
/**
 * DataDemo类的属性名不能有大写，
**/
public class ExcelWriteDemo {
    public static void main(String[] args) {
        String fileName = "D:\\excelDemo2.xlsx";

        EasyExcel.write(fileName, DataDemo.class).sheet("学生").doWrite(getData());

    }

    public static List<DataDemo> getData() {
        List<DataDemo> datas = new ArrayList<>();

        for (int i = 0; i < 10; i++) {
            DataDemo data = new DataDemo();
            data.setSno(i);
            data.setSname("lisi哈哈" + i);
            datas.add(data);
        }
        return datas;
    }


}
